package com.example.controller;

import com.example.common.Result;
import com.example.entity.Message;
import com.example.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/message")
@Api(tags = "通信模块")
public class MessageController {
    @Resource
    private MessageService messageService;

    @PostMapping("/getByUserId")
    @ApiOperation("查询消息")
    public Result<List<Message>> getByUserId(@RequestBody Message message){
        List<Message> byUserId = this.messageService.getByUserId(message);
        return Result.success(byUserId);
    }

    @PostMapping("/deliver")
    @ApiOperation("发送消息")
    public Result deliver(@RequestBody Message message){
        this.messageService.deliver(message);
        return Result.success();
    }


}
